#include <errno.h>
#include <string.h>
#include "err.h"

/*********************| extern data |*********************/
int csberrno = CSBERR_NOERR;

/*********************| extern functions |*********************/

const char*csb_errmsg(const int err)
{
	switch (err) {
	case CSBERR_SYSERR:
		return strerror(errno);
	case CSBERR_NOERR:
		return "没有发生错误";
	case CSBERR_OPENFILE:
		return "打开文件失败";
	case CSBERR_FILETOOLARGE:
		return "文件体积过大";
	case CSBERR_FILETYPE:
		return "文件类型错误, 或者版本号不符";
	case CSBERR_PARAM:
		return "参数错误";
	case CSBERR_SYSNOINITED:
		return "系统未被初始化";
	case CSBERR_FINIAL:
		return "达到数值边界，也许超过了某些有效范围的定义了";
	case CSBERR_BUF_NOT_ENOUGH:
		return "缓冲不足";
	default:
		return "未知错误";
	}
}

const char*csb_lasterr()
{
	return csb_errmsg(csberrno);
}
